package cn.classLoader;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;

/**
 * @author: lizemin
 * @version: 1.0
 */
public class DefineClassLoader {
    //这是一个main方法,是程序的入口
    public static void main(String[] args) throws MalformedURLException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        File file = new File("C:\\Users\\15871\\IdeaProjects\\LeeCode\\src");
        URI uri = file.toURI();
        URL url = uri.toURL();

        URLClassLoader urlClassLoader = new URLClassLoader(new URL[]{url});
        System.out.println("父类加载器:"+urlClassLoader.getParent());//默认为系统加载器

        Class<?> aClass = urlClassLoader.loadClass("cn.classLoader.Student");
        Object o = aClass.newInstance();
        System.out.println(o);


    }
}
